Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Latest commit

 

History

History
25 lines (20 loc) · 664 Bytes

10.7 - Process->setTimeout.md

File metadata and controls

25 lines (20 loc) · 664 Bytes

Process->setTimeout

设置管道读写操作的超时时间。

function Process->setTimeout(double $timeout)
  • $timeout单位为秒,支持浮点型,如1.5表示1s+500ms
  • 设置成功返回true
  • 设置失败返回false,可使用swoole_errno获取错误码

设置成功后,调用recvwrite在规定时间内未读取或写入成功,将返回false,可使用swoole_errno获取错误码。

1.9.21或更高版本可用

使用实例

$process = new \swoole_process(function(\swoole_process $process) {
    sleep(5);
});
$process->start();

$process->setTimeout(0.5);
$ret = $process->read();